<?php
/**
 * ShopProduct 类 负责管理产品数据
 * @package ShopProduct
 * @author Adair
 */

class ShopProduct{
	public $title = "default product";
	public $productMainName = "main name";
	public $productFirstName = "first name";
	public $prict = 0;
	
	

	function getProducer(){
		return "{$this->productFirstName}"." "."{$this->productMainName}";
	}
}

$product1 = new ShopProduct();
$product2 = new ShopProduct();

//var_dump($product1,$product2);
//print $product1->title;
$product1->title = "My Antonia";
$product1->arbitraryAddition = "treehouse";
//var_dump($product1);

$product1->productMainName = "Cather";
$product1->productFirstName = "Willa";

//echo "author: {$product1->getProducer()}</BR>";

//构造函数
class ShopProduct1{
	public $title = "default product";
	public $productMainName = "main name";
	public $productFirstName = "first name";
	public $prict = 0;
	
	function __construct($title,$firstName,$mainName,$price){
		$this->title = $title;
		$this->productFirstName = $firstName;
		$this->productMainName = $mainName;
		$this->price = $price;
	}

	function getProducer(){
		return "{$this->productFirstName}"." "."{$this->productMainName}";
	}
}

$product3 = new ShopProduct1("My Book","Adair","Z",6.88);
//echo "author: {$product3->getProducer()}\n";


class Wrong{
	function __construct($title,$firstName,$mainName,$price){
		$this->title = $title;
		$this->productFirstName = $firstName;
		$this->productMainName = $mainName;
		$this->price = $price;
	}	
}
